clear all
set more off

* set directory where code and data is stored
global main_dir // insert directory here

cd "$main_dir/data"
do "$main_dir/rent_processing_macros"

********************************************************************************

/**** 1. INITIAL RENT DATA HAS LISTINGS AS UNIQUE OBSERVATIONS, INCLUDES LOCATION,
PRICE, AND UNIT CHARACTERISTICS.  HERE WE EXPAND THE DATA TO INCLUDE AN OBSERVATION
FOR EACH UNIQUE PAIR OF A LISTING AND A NEARBY BUILDING AND ADD TRACT CHARACTERISTICS */

********************************************************************************

geocode_listings



********************************************************************************

/**** 2. MERGE IN BUILDING CHARACTERISTICS AND ORGANIZE/RENAME VARIABLES. THIS
PRODUCES BASE FILE WHERE LISTING/BUILDING PAIR IS AN OBSERVATION.  DUPLICATES
ARE INCLUDED WHEN LISTING IS NEAR MULTIPLE BUILDINGS.  SPECIFIC ANALYSIS FILES
ARE THEN CREATED FROM THIS BASE. */

********************************************************************************

add_building_info



********************************************************************************

/**** 3. CREATE DATA SETS FOR NEAR-FAR ANALYSES.  LOOP OVER DIFFERENT SAMPLE 
RESTRICTIONS TO CREATE DIFFERENT DATA SET FOR EACH FIGURE/TABLE. */

********************************************************************************

* dist list changes max dist, iso_list changes isolation criterita, g_list 
* selects gentrifying/not buildings
 
local dist_list 600 800
local iso_list 250 400
local g_list g ng

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	near_far_file
	
		}
	}
}


********************************************************************************

/**** 4. CREATE DATA SETS FOR NEAR-NEAR ANALYSES.  LOOP OVER DIFFERENT SAMPLE 
RESTRICTIONS TO CREATE DIFFERENT DATA SET FOR EACH FIGURE/TABLE. */

********************************************************************************

* dist list changes max dist, iso_list changes isolation criterita, g_list 
* selects gentrifying/not buildings

local dist_list 250 400
local iso_list 250 400
local g_list g ng

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	near_near_file
	
		}
	}
}
	
	
********************************************************************************

/**** 5. CREATE DATA SETS FOR DDD ANALYSES.  LOOP OVER DIFFERENT SAMPLE 
RESTRICTIONS TO CREATE DIFFERENT DATA SET FOR EACH FIGURE/TABLE. */

********************************************************************************

* dist list changes max dist, iso_list changes isolation criterita, g_list 
* selects gentrifying/not buildings

local dist_list 600 800
local iso_list 250 400
local g_list g ng

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	triple_diff_file
	
		}
	}
}		
	
	
	
	
********************************************************************************
********************************************************************************

* THE BELOW PROGRAMS CREATE DATA SETS THAT ARE ONLY USED IN APPENDIX EXERCISES

********************************************************************************

********************************************************************************
	
	
	
	
	
********************************************************************************

/**** A1. CREATE DATA SETS FOR FAR-FAR ANALYSES.  LOOP OVER DIFFERENT SAMPLE 
RESTRICTIONS TO CREATE DIFFERENT DATA SET FOR EACH FIGURE/TABLE. */

********************************************************************************

* dist list changes max dist, iso_list changes isolation criterita, g_list 
* selects gentrifying/not buildings
	
** make far-far file from the long data
local dist_list 600 800
local iso_list 250 400
local g_list g ng

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	far_far_file
	
		}
	}
}	


********************************************************************************

**** A2. CREATE DATA SET FOR LONG PRE-TREND ANALYSIS OF NEAR-FAR

********************************************************************************

local dist_list 600 
local iso_list 250 
local g_list g 

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	long_pretrend_file
	
		}
	}
}


********************************************************************************

**** A3. CREATE DATA SET FOR LONGER TIME PERIOD ANALYSIS OF NEAR-FAR

********************************************************************************
local dist_list 600 
local iso_list 250 
local g_list g 

foreach max_dist in `dist_list'{
	foreach iso_dist in `iso_list'{
		foreach g in `g_list'{
		
	global max_dist `max_dist'
	global iso_dist `iso_dist'
	global g `g'
	
	long_run_effect_file
	
		}
	}
}



********************************************************************************

**** A4 CREATE DATA SET FOR EMPIRICAL DERIVATIVE ANALYSIS

********************************************************************************
	
emp_derivative



********************************************************************************

**** A5 CREATE TWEAKED DATA SETS WITH DIFFERENT SAMPLE CRITERIA

********************************************************************************
	
alternative_data_sets





